#!/bin/sh


# Customize stuff in compton.conf
# picom --config /home/oll/.config/dwm/picom.conf &

# Startup programs
xrandr --dpi 112 &
setxkbmap -layout us,ru -option grp:caps_toggle, grp_led:scroll &
#/usr/bin/nm-applet &
#/usr/bin/gnome-volume-control-applet &
feh -z -Z --bg-scale /home/oll/.config/dwm/black.jpg &
#feh -z -Z -B black -b trans --bg-scale /home/jguldmyr/Pictures/Flow.png
#slstatus &

while true; do

	#while loop to update statusbar with some goodies
	{
		while true; do
			#battery=`awk '/charging state/{print $3}' < /proc/acpi/battery/BAT0/state`;
			#memfreak to get it in MB
			memfreak2=`grep MemFree /proc/meminfo | awk '{ print $2 }'`;

			memfreak=$(( $memfreak2/1024 ));
			#time
			CLK=$( date '+%Y-%m-%d %H:%M:%S' )
			#$( date +'%a %b %d %R:%S %Z' )
			#volume
#			VOL=$( amixer get Master | tail -1 | awk '{ print $5 }' | tr -d '[]' )
			#loadavg
			#AVG=$( cat /proc/loadavg | cut -d ' ' -f -3 )
			#network stats in Bytes
			#NW=$( dstat -n --nocolor 1 1 | tail -1 | awk '{ print $1, $2}' )
			#this one is not so good, increases a delay of 1-2s of the updating.
			#put it in the xsetrootname plz (tip of the day, do not put | as first char after "
			xsetroot -name "${memfreak}MiB $CLK "
			sleep 1
		done
	} &

	# Finally start dwm!
	dwm > logs.txt

	# I forgot what is this for, but I guess when you terminate
	# dwm it will restart and that while loop will too.
	kill $!
done
